package com.heima.utils.dao;

import com.heima.model.associate.Words;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

@Slf4j
@Component
@Transactional
@Data
public class DataDAO<T> {

    public DataDAO() {
        list = new ArrayList<>();
    }

    private List<T> list;

    public void save(List<T> cachedDataList) {
        for (int i = 0; i < cachedDataList.size(); i++) {
            T a = cachedDataList.get(i);
            if (a instanceof Words) {
                list.add(a);
            }
        }
    }
}
